package com.systemsjr.jrappointment.appointment;

import javax.swing.JComponent;

import org.springframework.richclient.form.binding.swing.SwingBindingFactory;
import org.springframework.richclient.form.builder.TableFormBuilder;

import com.systemsjr.jrappointment.appointment.vo.AppointmentSearchCriteria;
import com.systemsjr.jrappointment.customer.vo.CustomerVO;
import com.systemsjr.jrappointment.invoice.vo.InvoiceVO;
import com.systemsjr.jrappointment.utils.ServiceUtils;
import com.systemsjr.jrlib.richclient.BaseItemFilterForm;
import com.systemsjr.jrlib.richclient.table.JRTableUtils;

public class AppointmentFilterForm extends BaseItemFilterForm<AppointmentSearchCriteria> {

	public AppointmentFilterForm() {
		super("appointmentSearchForm");
	}

	@Override
	protected void doSearch() {
		
		commit();
		AppointmentSearchCriteria criteria = (AppointmentSearchCriteria) getFormObject();	
		JRTableUtils.refreshTable(table, ServiceUtils.getAppointmentService().search(criteria));
	}
	

	@Override
	protected void doCreateFormControl() {
		
		builder.row();
		builder.add("customer.phoneNumber");
		builder.row();
		builder.add("customer.name");
		builder.row();
	}
	
	@Override
	protected Object newFormObject() {
		AppointmentSearchCriteria criteria = new AppointmentSearchCriteria();
		criteria.setCustomer(new CustomerVO());
		criteria.setInvoice(new InvoiceVO());
		return criteria;
	}
}
